package logic

import (
	"context"
	"goodsrpc/goods"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderInquiryLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewOrderInquiryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderInquiryLogic {
	return &OrderInquiryLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *OrderInquiryLogic) OrderInquiry(req *types.OrderInquiryRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	inquiry, err := l.svcCtx.Goods.OrderInquiry(l.ctx, &goods.OrderInquiryRequest{Id: req.Id})
	if err != nil {
		return &types.Response{
			Code: 500,
			Msy:  err.Error(),
			Data: nil,
		}, nil
	}
	return &types.Response{
		Code: 200,
		Msy:  "房源展示成功",
		Data: inquiry,
	}, nil
}
